<!DOCTYPE html>
<!--suppress HtmlUnknownAttribute -->
<html lang="zh-Hans-CN" xmlns:th="http://www.thymeleaf.org">
<head>
  <th:block th:include="include :: header"/>
  <title>新增辖区</title>
</head>
<body>
<form action="javascript:void(0);" class="layui-form">
  <div class="mainBox">
    <div class="main-container">

      <div class="layui-form-item">
        <label for="city" class="layui-form-label">省辖市：</label>
        <div class="layui-input-block">
          <input id="city" class="layui-input" lay-verify="required" name="city"
                 placeholder="请输入城市" type="text"/>
        </div>
      </div>
      <div class="layui-form-item">
        <label for="county" class="layui-form-label">区/县：</label>
        <div class="layui-input-block">
          <input id="county" class="layui-input" lay-verify="required" name="county"
                 placeholder="请输入区县" type="text"/>
        </div>
      </div>
      <div class="layui-form-item">
        <label for="districtCode" class="layui-form-label">行政代码：</label>
        <div class="layui-input-block">
          <input id="districtCode" class="layui-input" lay-verify="required"
                 name="districtCode" placeholder="请输入行政区划代码" type="text"/>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">水文地区：</label>
        <div class="layui-input-block">
          <!--suppress HtmlFormInputWithoutLabel -->
          <input lay-skin="primary" name="regionCodeId"
                 th:checked="${code.get('checked')}" th:each="code:${codes}" th:title="${code.name}"
                 th:value="${code.id}" type="radio">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="sort" class="layui-form-label">排序码：</label>
        <div class="layui-input-block">
          <input id="sort" class="layui-input" lay-verify="required" name="sort"
                 placeholder="请输入排序码" type="number"/>
        </div>
      </div>
    </div>
  </div>
  <div class="bottom">
    <div class="button-container">
      <button class="pear-btn pear-btn-primary pear-btn-sm" lay-filter="well-region-save" lay-submit="" type="submit">
        <i class="layui-icon layui-icon-ok"></i>
        提交
      </button>
      <button class="pear-btn pear-btn-sm" type="reset">
        <i class="layui-icon layui-icon-refresh"></i>
        重置
      </button>
    </div>
  </div>
</form>
</body>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">

  layui.use(['form', 'jquery', 'dictionary', 'popup'], function () {
    let form = layui.form;
    let $ = layui.jquery;

    let prefix = "/well/region/";

    form.on('submit(well-region-save)', function (data) {
      $.ajax({
        url: prefix + 'save',
        data: JSON.stringify(data.field),
        dataType: 'json',
        contentType: 'application/json',
        type: 'post',
        success: function (result) {
          if (result.success) {
            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
              parent.layer.close(parent.layer.getFrameIndex(window.name));
              parent.layui.table.reload("well-region-table");
            });
          } else {
            layer.msg(result.msg, {icon: 2, time: 1000});
          }
        }
      })
      return false;
    });
  });
</script>
</html>
